home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / loadAnimMenuLibrary.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  47.5 KB  |  1,408 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-2001 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. //
  34. //  Alias|Wavefront Script File
  35. //  MODIFY THIS AT YOUR OWN RISK
  36. //
  37. //  Creation Date:  November 20, 1996
  38. //  Author:         mm
  39. //
  40. //  Description:
  41. //      This script contains common menu definition routines shared
  42. //    between the graph editor and the dope sheet.
  43. //
  44. //        A call to the proc 'loadAnimMenuLibrary' will make sure that
  45. //    all the other helper procs defined in here are loaded and available
  46. //
  47. //    Procs defined within this script:
  48. //
  49. //    defineEditMenu (string $editor, string $animEditor, string $parentMenu, string $buildMenuCommand)
  50. //        Define the elements of the Edit subMenu
  51. //
  52. //    defineListMenu (string $editor, string $animEditor, string $parentMenu)
  53. //        Define the elements of the Options subMenu
  54. //
  55. //    defineTangentsMenu (string $editor, string $animEditor, string $parentMenu)
  56. //        Define the elements of the Tangents subMenu
  57. //
  58. //  Input Arguments:
  59. //      None.
  60. //
  61. //  Return Value:
  62. //      None.
  63. //
  64.  
  65. global string $gEditorList[];
  66. global string $gDefaultConnection[];
  67.  
  68. global proc performEulerFilter(string $selectionConnection) 
  69. {
  70.     string $objs[] = `selectionConnection -q -object $selectionConnection`;
  71.     int $nObjs = size($objs);
  72.     int $i = 0;
  73.     string $cmd = "filterCurve ";
  74.     for ($i = 0; $i < $nObjs ; $i++) {
  75.         $cmd += (" " + $objs[$i]);
  76.     }
  77.  
  78.     if ($nObjs > 0) {
  79.         evalEcho ($cmd);
  80.     }
  81. }
  82.  
  83. global proc performRotationInterpolation( string $mode, string $selectionConnection ) 
  84. {
  85.     // Query the curves which are selected in the graph editor viewport
  86.     // and append the selected names to a rotationInterpolation command
  87.     // string.
  88.     //
  89.     string $viewportSel[];
  90.     if ( `isTrue SomethingSelected` != 0 ) {
  91.         catch( $viewportSel = `keyframe -an keys -query -name` );
  92.     }
  93.     string $cmd = "rotationInterpolation -c " + $mode;
  94.     int $i;
  95.     int $viewportCount = size( $viewportSel );
  96.     for ( $i = 0; $i < $viewportCount; $i++ ) {
  97.          $cmd += (" " + $viewportSel[$i]);
  98.     }
  99.  
  100.     // Query the curves which are selected in the graph editor outliner
  101.     // and append the selected names to the command string.
  102.     //
  103.     string $outlinerSel[] = `selectionConnection -q -object $selectionConnection`;
  104.     int $outlinerCount = size( $outlinerSel );
  105.     for ( $i = 0; $i < $outlinerCount; $i++ ) {
  106.          $cmd += (" " + $outlinerSel[$i]);
  107.     }
  108.  
  109.     // If any curves were selected, execute the command string which we
  110.     // built up.
  111.     //
  112.     if ( $viewportCount + $outlinerCount > 0 ) {
  113.         evalEcho( $cmd );
  114.     }
  115. }
  116.  
  117. proc int
  118. findEditorEntry (string $editor)
  119. //
  120. //    Procedure Name:
  121. //        findEditorEntry
  122. //
  123. //    Description:
  124. //        Helper method to find the index entry of a registered editor
  125. //
  126. //  Input Arguments:
  127. //        string $editor            The name of the editor that is registered
  128. //
  129. //  Return Value:
  130. //      int the index entry in $editorList (-1 if it is not registered)
  131. //
  132. {
  133.     global string $gEditorList[];
  134.     int $length = size ($gEditorList);
  135.     for ($i = 0; $i < $length; $i++) {
  136.         if ($gEditorList[$i] == $editor) {
  137.             return ($i);
  138.         }
  139.     }
  140.     return (-1);
  141. }
  142.  
  143. global proc string
  144. getDefaultConnection (string $editor)
  145. //
  146. //    Procedure Name:
  147. //        getDefaultConnection
  148. //
  149. //    Description:
  150. //        Helper method to find the name of the default selection connection
  151. //    for a registered editor
  152. //
  153. //  Input Arguments:
  154. //        string $editor            The name of the editor that is registered
  155. //
  156. //  Return Value:
  157. //      string the name of the default selection connection, "animationList"
  158. //    if the editor is not registered
  159. //
  160. {
  161.     global string $gDefaultConnection[];
  162.  
  163.     int $entry = findEditorEntry ($editor);
  164.     if ($entry == -1) {
  165.         return ("animationList");
  166.     }
  167.     return ($gDefaultConnection[$entry]);
  168. }
  169.  
  170. global proc
  171. registerEditor (string $editor, string $defaultConnection)
  172. //
  173. //    Procedure Name:
  174. //        registerEditor
  175. //
  176. //    Description:
  177. //        Helper method to register the name of the default selection connection
  178. //    for this editor
  179. //
  180. //  Input Arguments:
  181. //        string $editor            The name of the editor that is being registered
  182. //        string $defaultConnection    The name of the default selection connection
  183. //
  184. //  Return Value:
  185. //      None.
  186. //
  187. {
  188.     global string $gEditorList[];
  189.     global string $gDefaultConnection[];
  190.  
  191.     int $entry = findEditorEntry ($editor);
  192.     if ($entry == -1) {
  193.         int $length = size ($gEditorList);
  194.         $gEditorList[$length] = $editor;
  195.         $gDefaultConnection[$length] = $defaultConnection;
  196.     }
  197. }
  198.  
  199. global proc
  200. buildAnimEditMenu (string $editor, string $animEditor, string $parentMenu, string $options, string $buildMenuCommand)
  201. //
  202. //    Procedure Name:
  203. //        buildAnimEditMenu
  204. //
  205. //    Description:
  206. //        This actually builds the edit subMenu if necessary
  207. //
  208. //  Input Arguments:
  209. //        string $editor            The name of the editor that this submenu
  210. //                                is being attached to
  211. //        string $animEditor        The name of the animation editor that this submenu
  212. //                                is being attached to
  213. //        string $parentMenu        The name of the parent menu that this
  214. //                                submenu is being attached to
  215. //        string $options            Options for this proc
  216. //                                Option words are specified within the
  217. //                                the string, with each option seperated
  218. //                                by a space (e.g. "bufferCurve otherOption")
  219. //            Current options:
  220. //                noOptions        A nice "do nothing" string to pass
  221. //                bufferCurve        Issue commands to (possibly) create buffer curves
  222. //        string $buildMenuCommand
  223. //                                An optional command to be called when
  224. //                                this menu is built.  The command will
  225. //                                be called with $editor $parentMenu
  226. //
  227. //  Return Value:
  228. //      None.
  229. //
  230. {
  231.     setParent -menu $parentMenu;
  232.     if (`menu -query -numberOfItems $parentMenu` != 0) {
  233.         return;
  234.     }
  235.  
  236.     // Check for the bufferCurve option
  237.     //
  238.     int $performBase = 0;
  239.     if (match ("bufferCurve", $options) == "bufferCurve") {
  240.         $performBase = 3;
  241.     }
  242.  
  243.     // The dimWhen's below allow the Undo and Redo menu items to dim themselves
  244.     // as approriate.  However the main undo menu items no longer do this
  245.     // because Irix cannot handle roll over help on dimmed items, so this block
  246.     // is commented out for now
  247.     //
  248.     menuItem -label "Undo"
  249.         -annotation "Undo: Undo the last action"
  250.         -command "undo"
  251.         animUndoItem;
  252. //    dimWhen -false "UndoAvailable" animUndoItem;
  253.     menuItem -label "Redo"
  254.         -annotation "Redo: Redo the last undone action"        
  255.         -command "redo"
  256.         animRedoItem;
  257. //    dimWhen -false "RedoAvailable" animRedoItem;
  258.  
  259.     menuItem -divider true;
  260.  
  261.     string $selectionConnection = `editor -query -selectionConnection $editor`;
  262.     if (match ("bufferCurve", $options) == "bufferCurve") {
  263.         $selectionConnection = $animEditor;
  264.     }
  265.  
  266.     menuItem -label "Cut"
  267.         -annotation "Cut: Select object or curve segment"
  268.         -command ("performCutKeyArgList 1 {\"" + $performBase + "\", \"" + $selectionConnection + "\", \"1\"}") 
  269.         -dragMenuCommand( "performCutKeyArgList 1 {\"" + ($performBase + 2) + "\", \"" + $selectionConnection + "\", \"1\"}")
  270.         cutItem;
  271.     menuItem -optionBox true 
  272.         -label "Cut Option Box"
  273.         -command ("performCutKeyArgList 1 {\"" + ($performBase + 1) + "\", \"" + $selectionConnection + "\", \"1\"}" ) 
  274.         cutKeyDialogItem;
  275.     menuItem -label "Copy"
  276.         -annotation "Copy: Select object or curve segment"        
  277.         -command ("performCopyKeyArgList 1 {\"" + $performBase + "\", \"" + $selectionConnection + "\", \"1\"}") 
  278.         -dragMenuCommand( "performCopyKeyArgList 1 {\"" + ($performBase + 2) + "\", \"" + $selectionConnection + "\", \"1\"}")
  279.         copyItem;
  280.     menuItem -optionBox true 
  281.         -label "Copy Option Box"
  282.         -command ("performCopyKeyArgList 1 {\"" + ($performBase + 1) + "\", \"" + $selectionConnection + "\", \"1\"}" )
  283.         copyKeyDialogItem;
  284.     menuItem -label "Paste"
  285.         -annotation "Paste: Select object or curve segment"
  286.         -command ("performPasteKeyArgList 1 {\"" + $performBase + "\", \"" + $selectionConnection + "\", \"1\"}")
  287.         -dragMenuCommand( "performPasteKeyArgList 1 {\"" + ($performBase + 2) + "\", \"" + $selectionConnection + "\", \"1\"}")
  288.         pasteItem;
  289.     menuItem -optionBox true 
  290.         -label "Paste Option Box"
  291.         -command ("performPasteKeyArgList 1 {\"" + ($performBase + 1) + "\", \"" + $selectionConnection + "\", \"1\"}")
  292.         pasteKeyDialogItem;
  293.     menuItem -label "Delete"
  294.         -annotation "Delete: Select key(s)"
  295.         -command ("performClearKeyArgList 1 {\"" + $performBase + "\", \"" + $selectionConnection + "\", \"0\", \"1\"}")
  296.         -dragMenuCommand( "performClearKeyArgList 1 {\"" + ($performBase + 2) + "\", \"" + $selectionConnection + ", \"0\", \"1\"}")
  297.         clearItem;
  298.     menuItem -optionBox true 
  299.         -label "Delete Option Box"
  300.         -command ("performClearKeyArgList 1 {\"" + ($performBase + 1) + "\", \"" + $selectionConnection + "\", \"0\", \"1\"}")
  301.         clearKeyDialogItem;
  302.     menuItem -label "Scale"
  303.         -annotation "Scale: Select keys"        
  304.         -command ("performScaleKeyArgList 1 {\"" + $performBase + "\", \"" + $selectionConnection + "\", \"1\"}" )
  305.         -dragMenuCommand( "performScaleKeyArgList 1 {\"" + ($performBase + 2) + "\", \"" + $selectionConnection + "\", \"1\"}")
  306.         scaleItem;
  307.     menuItem -optionBox true 
  308.         -label "Scale Option Box"
  309.         -command ("performScaleKeyArgList 1 {\"" + ($performBase + 1) + "\", \"" + $selectionConnection + "\", \"1\"}")
  310.         scaleKeyDialogItem;
  311.  
  312.     menuItem -divider true;
  313.  
  314.     menuItem -label "Snap"
  315.         -annotation "Snap: Select object or key(s)"        
  316.         -command ("performSnapKeyArgList 1 { \"" + $performBase + "\", \"" + $selectionConnection + "\", \"1\" }" )
  317.         -dragMenuCommand( "performSnapKeyArgList 1 { \"" + ($performBase + 2) + "\", \"" + $selectionConnection + "\", \"1\" }" )
  318.         snapItem;
  319.     menuItem -optionBox true 
  320.         -label "Snap Option Box"
  321.         -command ("performSnapKeyArgList 1 { \"" + ($performBase + 1) + "\", \"" + $selectionConnection + "\", \"1\" }")
  322.         snapKeyDialogItem;
  323.  
  324.     menuItem -label "Select Unsnapped"
  325.         -annotation "Select Unsnapped: Select nothing or select a curve"
  326.         -command ("performSnapKeyArgList 1 { \"6\", \"" + $selectionConnection + "\", \"1\" } " )
  327.         -dragMenuCommand( "performSnapKeyArgList 1 { \"7\", \"" + $selectionConnection + "\", \"1\" } " )
  328.         selectUnsnappedItem;
  329.  
  330.     if ($buildMenuCommand != "") {
  331.         eval (($buildMenuCommand + " " + $animEditor + " " + $parentMenu));
  332.     }
  333. }
  334.  
  335. global proc
  336. defineEditMenu (string $editor, string $animEditor, string $parentMenu, string $options, string $buildMenuCommand)
  337. //
  338. //    Procedure Name:
  339. //        defineEditMenu
  340. //
  341. //    Description:
  342. //        This creates the submenu for edit functionality
  343. //
  344. //    Example:
  345. //        Create a menu that this submenu is to be attached to
  346. //    (make sure that the menu is defined to allow option boxes)
  347. //
  348. //        menuItem -label "Edit"
  349. //            -allowOptionBoxes true
  350. //            -subMenu true
  351. //            editHierItem;
  352. //            defineEditMenu $editor "editHierItem" "optionalBuildMenuCommand"; 
  353. //        setParent -menu ..;
  354. //
  355. //  Input Arguments:
  356. //        string $editor            The name of the editor that this submenu
  357. //                                is being attached to
  358. //        string $parentMenu        The name of the parent menu that this
  359. //                                submenu is being attached to
  360. //        string $options            Options for this proc
  361. //                                Option words are specified within the
  362. //                                the string, with each option seperated
  363. //                                by a space (e.g. "bufferCurve otherOption")
  364. //            Current options:
  365. //                noOptions        A nice "do nothing" string to pass
  366. //                bufferCurve        Issue commands to (possibly) create buffer curves
  367. //        string $buildMenuCommand
  368. //                                An optional command to be called when
  369. //                                this menu is built.  The command will
  370. //                                be called with $editor $parentMenu
  371. //
  372. //  Return Value:
  373. //      None.
  374. //
  375. {
  376.     setParent -menu $parentMenu;
  377.  
  378.     menu -edit
  379.         -postMenuCommand ("buildAnimEditMenu " + $editor + " " + $animEditor + " " + $parentMenu + "\"" + $options + "\"" + " " + "\"" + $buildMenuCommand + "\"")
  380.         $parentMenu;
  381.  
  382.     // This section will allow the undo item to display what is going to
  383.     // be undone.  This is the fix for bug 55712.  However the main undo
  384.     // menu items no longer show this, so this block is commented out for
  385.     // now
  386.     //
  387. //mm    menu -edit
  388. //mm        -postMenuCommand ("handleEditMenuCmd " + $parentMenu)
  389. //mm        $parentMenu;
  390.  
  391. }
  392.  
  393. global proc
  394. handleEditMenuCmd (string $parentMenu)
  395. //
  396. //  Procedure Name:
  397. //      handleEditMenuCmd
  398. //
  399. //  Description:
  400. //        This proc is a -postMenuCommand callback which sets the state of
  401. //    menu items in the Edit menu.
  402. //
  403. //  Input Arguments:
  404. //      None.
  405. //
  406. //  Return Value:
  407. //      None.
  408. //
  409. {
  410.     string $undoName;
  411.     string $buffer[];
  412.     
  413.     setParent -menu $parentMenu;
  414.  
  415.     $undoName = `undoInfo -query -undoName`;
  416.     tokenize ($undoName, $buffer);
  417.     $undoName = ("Undo " + $buffer[0]);
  418.     menuItem -edit -label $undoName animUndoItem;
  419.  
  420.     $undoName = `undoInfo -query -redoName`;
  421.     tokenize ($undoName, $buffer);
  422.     $undoName = ("Redo " + $buffer[0]);
  423.     menuItem -edit -label $undoName animRedoItem;
  424. }
  425.  
  426. global proc int
  427. isAutoLoad (string $editor)
  428. {
  429.     // First, find out what is connected to this editor
  430.     //
  431.     string $mainListConnection = `editor -query -mainListConnection $editor`;
  432.  
  433.     // If it is NOT the active list, then check it off
  434.     //
  435.     string $defaultConnection = getDefaultConnection ($editor);
  436.     if(( $mainListConnection != "activeList" ) 
  437.     && ( $mainListConnection != $defaultConnection )) 
  438.     {
  439.         return (0);
  440.     }
  441.     else if (`selectionConnection -query -lock $mainListConnection`) {
  442.         return (0);
  443.     }
  444.     return (1);
  445. }
  446.  
  447. global proc
  448. toggleAutoLoad (string $editor, int $toggle)
  449. //
  450. //  Procedure Name:
  451. //      toggleAutoLoad
  452. //
  453. //  Description:
  454. //        This proc is a helper to toggle the auto load state
  455. //        of the outliner.
  456. //
  457. //  Input Arguments:
  458. //      None.
  459. //
  460. //  Return Value:
  461. //      None.
  462. //
  463. {
  464.     // First, find out what is connected to this editor
  465.     //
  466.     string $mainListConnection = `editor -query -mainListConnection $editor`;
  467.     // If it is NOT the active list, then force it to use the active list
  468.     //
  469.     string $defaultConnection = getDefaultConnection ($editor);
  470.     if (($mainListConnection != "activeList") && ($mainListConnection != $defaultConnection)) {
  471.         editor -edit -unlockMainConnection $editor;
  472.         editor -edit -mainListConnection $defaultConnection $editor;
  473.     }
  474.     else if ($toggle) {
  475.         editor -edit -unlockMainConnection $editor;
  476.     }
  477.     else {
  478.         editor -edit -lockMainConnection $editor;
  479.     }
  480.  
  481.     // The best way to resolve the button name is to pass in the full
  482.     // path to the button, however toggleAutoLoad is called from several
  483.     // places (including some c++ code) and this makes it difficult.
  484.     // So instead we will use a carefully constructed name for the
  485.     // button
  486.     //
  487.     if (`iconTextCheckBox -exists ($editor + "loadToggleButton")`) {
  488.         iconTextCheckBox -edit
  489.             -value `isAutoLoad $editor`
  490.             ($editor + "loadToggleButton");
  491.     }
  492.  
  493.     if (`iconTextButton -exists ($editor + "reloadButton")`) {
  494.         iconTextButton -edit
  495.             -enable (!`isAutoLoad $editor`)
  496.             ($editor + "reloadButton");
  497.     }
  498. }
  499.  
  500. global proc
  501. doReload (string $editor)
  502. //
  503. //  Procedure Name:
  504. //      doReload
  505. //
  506. //  Description:
  507. //        This proc is a helper to have the outliner do a reload.
  508. //
  509. //  Input Arguments:
  510. //      None.
  511. //
  512. //  Return Value:
  513. //      None.
  514. //
  515. {
  516.     // First, find out what is connected to this editor
  517.     //
  518.     string $mainListConnection = `editor -query -mainListConnection $editor`;
  519.     // If it is NOT the active list, then force it to use the active list
  520.     //
  521.     string $defaultConnection = getDefaultConnection ($editor);
  522.     if (($mainListConnection != "activeList") && ($mainListConnection != $defaultConnection)) {
  523. //        editor -edit -unlockMainConnection $editor;
  524. //        editor -edit -mainListConnection $defaultConnection $editor;
  525. //        editor -edit -lockMainConnection $editor;
  526.         editor -edit -forceMainConnection $defaultConnection $editor;
  527.     }
  528.     // Otherwise switch the lock on the list off and on
  529.     //
  530.     else if (`selectionConnection -query -lock $mainListConnection`) {
  531. //        editor -edit -unlockMainConnection $editor;
  532. //        editor -edit -mainListConnection $defaultConnection $editor;
  533. //        editor -edit -lockMainConnection $editor;
  534.         editor -edit -forceMainConnection $defaultConnection $editor;
  535.     }
  536. }
  537.  
  538. global proc
  539. handleListMenuCmd (string $options, string $editor, string $animEditor, string $parentMenu, string $buildMenuCommand)
  540. //
  541. //  Procedure Name:
  542. //      handleListMenuCmd
  543. //
  544. //  Description:
  545. //        This proc is a -postMenuCommand callback which sets the state of
  546. //    menu items in the List menu.
  547. //
  548. //  Input Arguments:
  549. //        string $options            Options for this menu
  550. //                                Option words are specified within the
  551. //                                the string, with each option seperated
  552. //                                by a space (e.g. "noScroll otherOption")
  553. //
  554. //            Current options:
  555. //                noOptions        A nice "do nothing" string to pass
  556. //                useHier            Add a "Hierarchy Below" entry
  557. //
  558. //  Return Value:
  559. //      None.
  560. //
  561. {
  562.     // Set the proper check state of the AutoLoad menu
  563.     //
  564.     setParent -menu $parentMenu;
  565.  
  566.     if (`menu -query -numberOfItems $parentMenu` == 0) {
  567.         if (match ("useHier", $options) == "useHier") {
  568.             menuItem -label "Hierarchy Below"
  569.                 -checkBox false
  570.                 -command ("setHierarchyBelow #1 " + $animEditor)
  571.                 hierItem;
  572.         }
  573.         menuItem -label "Auto Load Selected Objects"
  574.             -checkBox true
  575.             -annotation "Auto Load Curves for selected objects into the Graph Editor"
  576.             -command ("toggleAutoLoad " + $editor + " #1")
  577.             autoLoadItem;
  578.         menuItem -label "Load Selected Objects"
  579.             -annotation "Load Curves for selected objects into the Graph Editor"            
  580.             -command ("doReload " + $editor)
  581.             reloadItem;
  582.         menuItem -label "Add Selected Objects"
  583.             -annotation "Add Curves for selected objects into the Graph Editor"
  584.             -command ("addSelectedToEditor " + $editor)
  585.             addToListItem;
  586.  
  587.         string $menuItem = `menuItem -label "Bookmarks"
  588.             -subMenu true -aob true
  589.             bookMarkHierItem`;
  590.         menuItem -edit
  591.             -postMenuCommand ("buildBookmarkMenu -type bookmarkAnimCurves -editor " + $editor + " " + $menuItem)
  592.             $menuItem;
  593.             menuItem 
  594.                 -label "Bookmark Current Objects"
  595.                 -annotation "Bookmark Current Objects: Select curves"
  596.                 -command ("createBookmark " + $editor + " bookmarkAnimCurves false") 
  597.                 bookAnimMarkObjectsItem;
  598.                 menuItem -optionBox true
  599.                     -label "Bookmark Current Objects Option Box"
  600.                     -command ("createBookmark " + $editor + " bookmarkAnimCurves true")
  601.                     bookAnimMarkObjectsDialog;
  602. //        menuItem 
  603. //            -label "Bookmark Current Curves..." 
  604. //            -command ("createBookmark " + $editor + " bookmarkAnimCurves") 
  605. //            bookAnimMarkCurvesItem;
  606.             menuItem -divider true;
  607.             setParent -menu ..;
  608.  
  609.         if ($buildMenuCommand != "") {
  610.             eval (($buildMenuCommand + " " + $editor + " " + $animEditor + " " + $parentMenu));
  611.         }
  612.     }
  613.  
  614.     if (match ("useHier", $options) == "useHier") {
  615.         menuItem -edit
  616.             -checkBox `dopeSheetEditor -query -hierarchyBelow $animEditor`
  617.             hierItem;
  618.     }
  619.  
  620.     // First, find out what is connected to this editor
  621.     //
  622.     string $mainListConnection = `editor -query -mainListConnection $editor`;
  623.     if ($mainListConnection == "") {
  624.         if (`modelEditor -exists $editor`) {
  625.             $mainListConnection = "activeList";
  626.         }
  627.     }
  628.  
  629.     // If it is NOT the active list, then check it off
  630.     //
  631.     string $defaultConnection = getDefaultConnection ($editor);
  632.     if(( $mainListConnection != "activeList") 
  633.     && ( $mainListConnection != $defaultConnection )) 
  634.     {
  635.         menuItem -edit -checkBox off autoLoadItem;
  636.         menuItem -edit -enable true reloadItem;
  637.         menuItem -edit -enable true addToListItem;
  638.     }
  639.     else if (`selectionConnection -query -lock $mainListConnection`) {
  640.         menuItem -edit -checkBox off autoLoadItem;
  641.         menuItem -edit -enable true reloadItem;
  642.         menuItem -edit -enable true addToListItem;
  643.     }
  644.     else {
  645.         menuItem -edit -checkBox on autoLoadItem;
  646.         menuItem -edit -enable false reloadItem;
  647.         menuItem -edit -enable false addToListItem;
  648.     }
  649. }
  650.  
  651. global proc
  652. defineListMenu (string $options, string $editor, string $animEditor,
  653.                 string $parentMenu, string $buildMenuCommand)
  654. //
  655. //    Procedure Name:
  656. //        defineListMenu
  657. //
  658. //    Description:
  659. //        This creates the submenu for list functionality
  660. //
  661. //    Example:
  662. //        Create a menu that this submenu is to be attached to
  663. //    (make sure that the menu is defined to allow option boxes)
  664. //
  665. //        menuItem -label "List"
  666. //            -allowOptionBoxes true
  667. //            -subMenu true
  668. //            optionsHierItem;
  669. //            defineListMenu $editor $animEditor "optionsHierItem"; 
  670. //            {further menu items could be defined here}
  671. //        setParent -m ..;
  672. //
  673. //  Input Arguments:
  674. //        string $editor            The name of the editor that this submenu
  675. //                                is being attached to
  676. //        string $parentMenu        The name of the parent menu that this
  677. //                                submenu is being attached to
  678. //        string $options            Options for this menu
  679. //                                Option words are specified within the
  680. //                                the string, with each option seperated
  681. //                                by a space (e.g. "noScroll otherOption")
  682. //
  683. //            Current options:
  684. //                noOptions        A nice "do nothing" string to pass
  685. //                useHier            Add a "Hierarchy Below" entry
  686. //
  687. //  Return Value:
  688. //      None.
  689. //
  690. {
  691.     setParent -menu $parentMenu;
  692.     menu -edit
  693.         -postMenuCommand ("handleListMenuCmd " + $options + " " + $editor + " " + $animEditor + " " + $parentMenu + "\"" + $buildMenuCommand + "\"")
  694.         $parentMenu;
  695. }
  696.  
  697. global proc
  698. doKeyTangent (string $commandOptions, string $selectionConnection, string $options)
  699. //
  700. //  Procedure Name:
  701. //      doKeyTangent
  702. //
  703. //  Description:
  704. //        This is a helper proc which will issue the proper form of the
  705. //        keyTangent command, depending upon whether or not keys are active.
  706. //
  707. //  Input Arguments:
  708. //        string $commandOptions            Options to be passed to the keyTangent
  709. //                                        command
  710. //        string $selectionConnection        The name of the selection connection
  711. //                                        that contains potential objects to
  712. //                                        perform the keyTangent command upon
  713. //        string $options                Options for this proc
  714. //                                        Option words are specified within the
  715. //                                        the string, with each option seperated
  716. //                                        by a space (e.g. "bufferCurve otherOption")
  717. //            Current options:
  718. //                noOptions                A nice "do nothing" string to pass
  719. //                bufferCurve                Issue commands to (possibly) create buffer curves
  720. //
  721. //  Return Value:
  722. //      None.
  723. //
  724. {
  725.     // Build up the command string
  726.     //
  727.     string $command = ("keyTangent " + $commandOptions);
  728.  
  729.     string $realConnection = $selectionConnection;
  730.  
  731.     // Check for the bufferCurve option
  732.     //
  733.     if (match ("bufferCurve", $options) == "bufferCurve") {
  734.         $realConnection = `editor -query -mainListConnection $selectionConnection`;
  735.         // Check to see if we need to create buffer curves
  736.         //
  737.         if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
  738.             $command = "bufferCurve -animation \"keys\" -overwrite false; " + $command;
  739.         }
  740.     }
  741.  
  742.     // Check to see if any keys are selected
  743.     //
  744.     int $keys = 0;
  745.     if (!`isTrue SomethingSelected`
  746.     ||    catch ($keys = `keyframe -animation keys -query -keyframeCount`)) {
  747.         $keys = 0;
  748.     }
  749.     if ($keys == 0) {
  750.         // No keys, so use the selection connection
  751.         //
  752.         $command = ($command + " -animation objects " + $realConnection);
  753.     }
  754.     // Now issue the command
  755.     //
  756.     evalEcho ($command);
  757. }
  758.  
  759. global proc
  760. doKeyEdit (string $commandOptions, string $selectionConnection, string $options)
  761. //
  762. //  Procedure Name:
  763. //      doKeyEdit
  764. //
  765. //  Description:
  766. //        This is a helper proc which will issue the proper form of the
  767. //        keyframe command, depending upon whether or not keys are active.
  768. //
  769. //  Input Arguments:
  770. //        string $commandOptions            Options to be passed to the keyTangent
  771. //                                        command
  772. //        string $selectionConnection        The name of the selection connection
  773. //                                        that contains potential objects to
  774. //                                        perform the keyTangent command upon
  775. //        string $options                Options for this proc
  776. //                                        Option words are specified within the
  777. //                                        the string, with each option seperated
  778. //                                        by a space (e.g. "bufferCurve otherOption")
  779. //            Current options:
  780. //                noOptions                A nice "do nothing" string to pass
  781. //                bufferCurve                Issue commands to (possibly) create buffer curves
  782. //                addInbetween            Create options to add an inbetween at the current time
  783. //                removeInbetween            Create options to remove an inbetween at the current time
  784. //
  785. //  Return Value:
  786. //      None.
  787. //
  788. {
  789.     // Build up the command string
  790.     //
  791.     string $command = ("keyframe " + $commandOptions);
  792.  
  793.     int $checkKeys = true;
  794.     // Check for the inbetweens
  795.     //
  796.     if (match ("addInbetween", $options) == "addInbetween") {
  797.         $command = $command + " -time \"" + `currentTime -query` + ":\" " +
  798.             "-relative -timeChange 1 -option over";
  799.         $checkKeys = false;
  800.     }
  801.     else if (match ("removeInbetween", $options) == "removeInbetween") {
  802.         $command = $command + " -time \"" + `currentTime -query` + ":\" " +
  803.             "-relative -timeChange -1 -option over";
  804.         $checkKeys = false;
  805.     }
  806.  
  807.     string $realConnection = $selectionConnection;
  808.  
  809.     // Check for the bufferCurve option
  810.     //
  811.     if (match ("bufferCurve", $options) == "bufferCurve") {
  812.         $realConnection = `editor -query -mainListConnection $selectionConnection`;
  813.         // Check to see if we need to create buffer curves
  814.         //
  815.         if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
  816.             $command = "bufferCurve -animation \"keys\" -overwrite false; " + $command;
  817.         }
  818.     }
  819.  
  820.     // Check to see if any keys are selected
  821.     //
  822.     int $keys = 0;
  823.     if ($checkKeys && (!`isTrue SomethingSelected`
  824.     ||    catch ($keys = `keyframe -animation keys -query -keyframeCount`))) {
  825.         $keys = 0;
  826.     }
  827.     if ($keys == 0) {
  828.         // No keys, so use the selection connection
  829.         //
  830.         $command = ($command + " -animation objects " + $realConnection);
  831.     }
  832.     // Now issue the command
  833.     //
  834.     evalEcho ($command);
  835. }
  836.  
  837. global proc
  838. doSetInfinity (string $commandOptions, string $selectionConnection, string $options)
  839. //
  840. //  Procedure Name:
  841. //      doSetInfinity
  842. //
  843. //  Description:
  844. //        This is a helper proc which will issue the proper form of the
  845. //        setInfinity command, depending upon whether or not keys are active.
  846. //
  847. //  Input Arguments:
  848. //        string $commandOptions            Options to be passed to the setInfinity
  849. //                                        command
  850. //        string $selectionConnection        The name of the selection connection
  851. //                                        that contains potential objects to
  852. //                                        perform the setInfinity command upon
  853. //        string $options                Options for this proc
  854. //                                        Option words are specified within the
  855. //                                        the string, with each option seperated
  856. //                                        by a space (e.g. "bufferCurve otherOption")
  857. //            Current options:
  858. //                noOptions                A nice "do nothing" string to pass
  859. //                bufferCurve                Issue commands to (possibly) create buffer curves
  860. //
  861. //  Return Value:
  862. //      None.
  863. //
  864. {
  865.     // Build up the command string
  866.     //
  867.     string $command = ("setInfinity " + $commandOptions);
  868.  
  869.     string $realConnection = $selectionConnection;
  870.  
  871.     // Check for the bufferCurve option
  872.     //
  873.     if (match ("bufferCurve", $options) == "bufferCurve") {
  874.         $realConnection = `editor -query -mainListConnection $selectionConnection`;
  875.         // Check to see if we need to create buffer curves
  876.         //
  877.         if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
  878.             $command = "bufferCurve -animation \"keys\" -overwrite false; " + $command;
  879.         }
  880.     }
  881.  
  882.     // Check to see if any keys are selected
  883.     //
  884.     int $keys = 0;
  885.     if (!`isTrue SomethingSelected`
  886.     ||    catch ($keys = `keyframe -animation keys -query -keyframeCount`)) {
  887.         $keys = 0;
  888.     }
  889.     if ($keys == 0) {
  890.         // No keys, so use the selection connection
  891.         //
  892.         $command = ($command + " " + $realConnection);
  893.     }
  894.     // Now issue the command
  895.     //
  896.     evalEcho ($command);
  897. }
  898.  
  899. global proc
  900. buildTangentsMenu (string $editor, string $animEditor, string $parentMenu, string $options, string $buildMenuCommand) 
  901. //
  902. //  Procedure Name:
  903. //      buildGraphEdTangentsMenu
  904. //
  905. //  Description:
  906. //        Creates the menu entries that control
  907. //        tangent settings in the graph editor.
  908. //
  909. //  Input Arguments:
  910. //        string $options            Options for this proc
  911. //                                Option words are specified within the
  912. //                                the string, with each option seperated
  913. //                                by a space (e.g. "bufferCurve otherOption")
  914. //            Current options:
  915. //                noOptions        A nice "do nothing" string to pass
  916. //                bufferCurve        Issue commands to (possibly) create buffer curves
  917. //
  918. //  Return Value:
  919. //      None.
  920. //
  921. {
  922.     setParent -menu $parentMenu;
  923.     if (`menu -query -numberOfItems $parentMenu` != 0) {
  924.         return;
  925.     }
  926.  
  927.     string $selectionConnection = `editor -query -selectionConnection $editor`;
  928.  
  929.     // Check for the bufferCurve option
  930.     //
  931.     if (match ("bufferCurve", $options) == "bufferCurve") {
  932.         $selectionConnection = $animEditor;
  933.     }
  934.  
  935.     menuItem -label "Spline"
  936.         -annotation "Spline Tangents: Select key(s)"
  937.         -command ("doKeyTangent \"-e -itt spline -ott spline\" " + $selectionConnection + " " + "\"" + $options + "\"");
  938.     menuItem -label "Linear"
  939.         -annotation "Linear Tangents: Select key(s)"        
  940.         -command ("doKeyTangent \"-e -itt linear -ott linear\" " + $selectionConnection + " " + "\"" + $options + "\"");
  941.     menuItem -label "Clamped"
  942.         -annotation "Clamped Tangents: Select key(s)"        
  943.         -command ("doKeyTangent \"-e -itt clamped -ott clamped\" " + $selectionConnection + " " + "\"" + $options + "\"");
  944.     menuItem -label "Stepped"
  945.         -annotation "Stepped Tangents: Select key(s)"        
  946.         -command ("doKeyTangent \"-e -ott step\" " + $selectionConnection + " " + "\"" + $options + "\"");
  947.     menuItem -label "Flat"
  948.         -annotation "Flat Tangents: Select key(s)"        
  949.         -command ("doKeyTangent \"-e -itt flat -ott flat\" " + $selectionConnection + " " + "\"" + $options + "\"");
  950. //    menuItem -label "Fast" -c "keyTangent -e -itt fast -ott fast" fastItem;
  951. //    menuItem -label "Slow" -c "keyTangent -e -itt slow -ott slow" slowItem;
  952.     menuItem -label "Fixed"
  953.         -annotation "Fixed Tangents: Select key(s)"        
  954.         -command ("doKeyTangent \"-e -itt fixed -ott fixed\" " + $selectionConnection + " " + "\"" + $options + "\"");
  955.  
  956.     menuItem -divider true;
  957.  
  958.     menuItem -label "In Tangent" -subMenu true -to true inTanHierItem;
  959.         menuItem -label "Spline"
  960.             -annotation "Spline In Tangents: Select key(s)"            
  961.             -command ("doKeyTangent \"-e -itt spline\" " + $selectionConnection + " " + "\"" + $options + "\"");
  962.         menuItem -label "Linear"
  963.             -annotation "Linear In Tangents: Select key(s)"                        
  964.             -command ("doKeyTangent \"-e -itt linear\" " + $selectionConnection + " " + "\"" + $options + "\"");
  965.         menuItem -label "Clamped"
  966.             -annotation "Clamped In Tangents: Select key(s)"            
  967.             -command ("doKeyTangent \"-e -itt clamped\" " + $selectionConnection + " " + "\"" + $options + "\"");
  968.         menuItem -label "Flat"
  969.             -annotation "Flat In Tangents: Select key(s)"                        
  970.             -command ("doKeyTangent \"-e -itt flat\" " + $selectionConnection + " " + "\"" + $options + "\"");
  971. //
  972. //    The next two are commented out for now - don't work properly
  973. //    yet, as the pre/post tangents are not being modified
  974. //
  975. //        menuItem -label "Fast" -c "keyTangent -e -itt fast";
  976. //        menuItem -label "Slow" -c "keyTangent -e -itt slow";
  977.         menuItem -label "Fixed"
  978.             -annotation "Fixed In Tangents: Select key(s)"
  979.             -command ("doKeyTangent \"-e -itt fixed\" " + $selectionConnection + " " + "\"" + $options + "\"");
  980.     setParent -m ..;
  981.  
  982.     menuItem -label "Out Tangent" -subMenu true -to true outTanHierItem;
  983.         menuItem -label "Spline"
  984.             -annotation "Spline Out Tangents: Select key(s)"
  985.             -command ("doKeyTangent \"-e -ott spline\" " + $selectionConnection + " " + "\"" + $options + "\"");
  986.         menuItem -label "Linear"
  987.             -annotation "Linear Out Tangents: Select key(s)"                        
  988.             -command ("doKeyTangent \"-e -ott linear\" " + $selectionConnection + " " + "\"" + $options + "\"");
  989.         menuItem -label "Clamped"
  990.             -annotation "Clamped Out Tangents: Select key(s)"
  991.             -command ("doKeyTangent \"-e -ott clamped\" " + $selectionConnection + " " + "\"" + $options + "\"");
  992.         menuItem -label "Flat"
  993.             -annotation "Flat Out Tangents: Select key(s)"            
  994.             -command ("doKeyTangent \"-e -ott flat\" " + $selectionConnection + " " + "\"" + $options + "\"");
  995. //
  996. //    The next two are commented out for now - don't work properly
  997. //    yet, as the pre/post tangents are not being modified
  998. //
  999. //        menuItem -label "Fast" -c "keyTangent -e -ott fast";
  1000. //        menuItem -label "Slow" -c "keyTangent -e -ott slow";
  1001.         menuItem -label "Fixed"
  1002.             -annotation "Fixed Tangents: Select key(s)"            
  1003.             -command ("doKeyTangent \"-e -ott fixed\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1004.     setParent -m ..;
  1005.  
  1006.     if ($buildMenuCommand != "") {
  1007.         eval (($buildMenuCommand + " " + $editor + " " + $animEditor + " " + $parentMenu));
  1008.     }
  1009. }
  1010.  
  1011. global proc
  1012. defineTangentsMenu (string $editor, string $animEditor, string $parentMenu, string $options, string $buildMenuCommand)
  1013. //
  1014. //    Procedure Name:
  1015. //        defineTangentsMenu
  1016. //
  1017. //    Description:
  1018. //        This creates the submenu for tangent setting functionality
  1019. //
  1020. //    Example:
  1021. //        Create a menu that this submenu is to be attached to
  1022. //
  1023. //        menuItem -label "Tangents"
  1024. //            -allowOptionBoxes false
  1025. //            -subMenu true
  1026. //            tangentsHierItem;
  1027. //            defineTangentsMenu $editor $animEditor "tangentsHierItem"; 
  1028. //            {further menu items could be defined here}
  1029. //        setParent -m ..;
  1030. //
  1031. //  Input Arguments:
  1032. //        string $editor            The name of the editor that this submenu
  1033. //                                is being attached to
  1034. //        string $parentMenu        The name of the parent menu that this
  1035. //                                submenu is being attached to
  1036. //        string $options            Options for this proc
  1037. //                                Option words are specified within the
  1038. //                                the string, with each option seperated
  1039. //                                by a space (e.g. "bufferCurve otherOption")
  1040. //            Current options:
  1041. //                noOptions        A nice "do nothing" string to pass
  1042. //                bufferCurve        Issue commands to (possibly) create buffer curves
  1043. //
  1044. //  Return Value:
  1045. //      None.
  1046. //
  1047. {
  1048.     setParent -menu $parentMenu;
  1049.     menu -edit
  1050.         -postMenuCommand ("buildTangentsMenu " + $editor + " " + $animEditor + " " + $parentMenu + "\"" + $options + "\"" + " " + "\"" + $buildMenuCommand + "\"")
  1051.         $parentMenu;
  1052. }
  1053.  
  1054. global proc
  1055. buildCurvesMenu (string $editor, string $animEditor, string $parentMenu, string $options, string $buildMenuCommand) 
  1056. //
  1057. //  Procedure Name:
  1058. //      buildCurvesMenu
  1059. //
  1060. //  Description:
  1061. //        Creates the menu entries that control
  1062. //        curve editing within an animation editor.
  1063. //
  1064. //  Input Arguments:
  1065. //        string $options            Options for this proc
  1066. //                                Option words are specified within the
  1067. //                                the string, with each option seperated
  1068. //                                by a space (e.g. "bufferCurve otherOption")
  1069. //            Current options:
  1070. //                noOptions        A nice "do nothing" string to pass
  1071. //                bufferCurve        Issue commands to (possibly) create buffer curves
  1072. //                useSmoothness    Add a "Curve Smoothness" entry
  1073. //
  1074. //  Return Value:
  1075. //      None.
  1076. //
  1077. {
  1078.     setParent -menu $parentMenu;
  1079.     if (`menu -query -numberOfItems $parentMenu` != 0) {
  1080.         // Update radio button checks for curve smoothness
  1081.         //
  1082.         if (match ("useSmoothness", $options) == "useSmoothness") {
  1083.             string $curveSmoothness = `animCurveEditor -query -smoothness $animEditor`;
  1084.             menuItem -edit
  1085.                 -radioButton ($curveSmoothness == "coarse")
  1086.                 coarseCurveItem;
  1087.             menuItem -edit
  1088.                 -radioButton ($curveSmoothness == "rough")
  1089.                 roughCurveItem;
  1090.             menuItem -edit
  1091.                 -radioButton ($curveSmoothness == "medium")
  1092.                 mediumCurveItem;
  1093.             menuItem -edit
  1094.                 -radioButton ($curveSmoothness == "fine")
  1095.                 fineCurveItem;
  1096.         }
  1097.  
  1098.         return;
  1099.     }
  1100.  
  1101.     string $selectionConnection = `editor -query -selectionConnection $editor`;
  1102.     string $realSelectionConnection = $selectionConnection;
  1103.  
  1104.     // Check for the bufferCurve option
  1105.     //
  1106.     int $performBase = 0;
  1107.     if (match ("bufferCurve", $options) == "bufferCurve") {
  1108.         $selectionConnection = $animEditor;
  1109.         $performBase = 3;
  1110.     }
  1111.  
  1112.     menuItem -label "Pre Infinity" -subMenu true -to true preInfinityHierItem;
  1113.         menuItem -label "Cycle"
  1114.             -annotation "Cycle: Select curve to cycle before its first key"
  1115.             -command ("doSetInfinity \"-pri cycle\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1116.         menuItem -label "Cycle with Offset"
  1117.             -annotation "Cycle with offset: Select curve to cycle with offset before its first key"
  1118.             -command ("doSetInfinity \"-pri cycleRelative\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1119.         menuItem -label "Oscillate"
  1120.             -annotation "Oscillate: Select curve to make it oscillate before its first key"
  1121.             -command ("doSetInfinity \"-pri oscillate\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1122.         menuItem -label "Linear"
  1123.             -annotation "Linear: Select curve to make it linear before its first key"
  1124.             -command ("doSetInfinity \"-pri linear\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1125.         menuItem -label "Constant"
  1126.             -annotation "Constant: Select curve to make it constant before its first key"            
  1127.             -command ("doSetInfinity \"-pri constant\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1128.     setParent -m ..; 
  1129.  
  1130.     menuItem -label "Post Infinity" -subMenu true -to true postInfinityHierItem;
  1131.         menuItem -label "Cycle"
  1132.             -annotation "Cycle: Select curve to cycle before its last key"
  1133.             -command ("doSetInfinity \"-poi cycle\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1134.         menuItem -label "Cycle with Offset"
  1135.             -annotation "Cycle with offset: Select curve to cycle with offset before its last key"
  1136.             -command ("doSetInfinity \"-poi cycleRelative\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1137.         menuItem -label "Oscillate"
  1138.             -annotation "Oscillate: Select curve to make it oscillate before its last key"
  1139.             -command ("doSetInfinity \"-poi oscillate\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1140.         menuItem -label "Linear"
  1141.             -annotation "Linear: Select curve to make it linear before its last key"            
  1142.             -command ("doSetInfinity \"-poi linear\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1143.         menuItem -label "Constant"
  1144.             -annotation "Constant: Select curve to make it constant before its last key"            
  1145.             -command ("doSetInfinity \"-poi constant\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1146.     setParent -m ..; 
  1147.  
  1148.     menuItem -divider true;
  1149.  
  1150.     if (match ("useSmoothness", $options) == "useSmoothness") {
  1151.         menuItem -label "Curve Smoothness" -subMenu true -tearOff true curveSmoothHierItem;
  1152.             //    Create a collection to keep the rb's in proper
  1153.             //    sync (IE: only one on at any one time. )
  1154.             //
  1155.             radioMenuItemCollection;
  1156.             menuItem -label "Coarse"
  1157.                 -radioButton true
  1158.                 -annotation "Coarse: Draw all curves at the coarsest resolution"
  1159.                 -command ("animCurveEditor -edit -smoothness coarse " + $animEditor) coarseCurveItem;
  1160.             menuItem -label "Rough"
  1161.                 -radioButton false
  1162.                 -annotation "Rough: Draw all curves at the rough resolution"
  1163.                 -command ("animCurveEditor -edit -smoothness rough " + $animEditor) roughCurveItem;
  1164.             menuItem -label "Medium"
  1165.                 -radioButton false
  1166.                 -annotation "Medium: Draw all curves at medium resolution"
  1167.                 -command ("animCurveEditor -edit -smoothness medium " + $animEditor) mediumCurveItem;
  1168.             menuItem -label "Fine"
  1169.                 -radioButton false
  1170.                 -annotation "Fine: Draw all curves at the highest resolution"
  1171.                 -command ("animCurveEditor -edit -smoothness fine " + $animEditor) fineCurveItem;
  1172.         setParent -m ..;
  1173.     }
  1174.  
  1175.     menuItem -label "Bake Channel"
  1176.         -annotation "Bake Channel: Select a curve"
  1177.         -c ("performBakeResults " + $performBase + " " + $selectionConnection) 
  1178.         -dragMenuCommand( "performBakeResults " + ($performBase + 2) + " \"" + 
  1179.                           $selectionConnection + "\"")
  1180.         bakeResultsItem;
  1181.         menuItem -optionBox true 
  1182.         -label "Bake Channel Option Box"
  1183.         -c ("performBakeResults " + ($performBase + 1) + " " + $selectionConnection) bakeResultsOptionsItem;
  1184.  
  1185.     menuItem -label "Change Rotation Interp" -subMenu true -tearOff true rotationInterpolationHierItem;
  1186.         //
  1187.         //    These are not radio buttons because we cannot show the type
  1188.         //    of the current selection: there could be many curves currently
  1189.         //    selected.
  1190.         //
  1191.         menuItem -label "Independent Euler"
  1192.             -annotation "Independent Euler: Select a rotation curve"
  1193.                 -c ("performRotationInterpolation none " + $realSelectionConnection);
  1194.         menuItem -label "Synchronized Euler"
  1195.             -annotation "Synchronized Euler: Select a rotation curve"
  1196.                 -c ("performRotationInterpolation euler " + $realSelectionConnection);
  1197.         menuItem -label "Synchronized Quaternion"
  1198.             -annotation "Synchronized Quaternion: Select a rotation curve"
  1199.                 -c ("performRotationInterpolation quaternion " + $realSelectionConnection);
  1200.     setParent -m ..;
  1201.     
  1202.     menuItem -label "Simplify Curve"
  1203.         -annotation "Simplify Curve: Select a curve"
  1204.         -c ("performSimplify " + $performBase + " " + $selectionConnection) 
  1205.         -dragMenuCommand( "performSimplify " + ($performBase + 2) + " \"" + 
  1206.                           $selectionConnection + "\"")
  1207.         simplifyItem;
  1208.     menuItem -optionBox true 
  1209.         -label "Simplify Curve Option Box"
  1210.         -c ("performSimplify " + ($performBase + 1) + " " + $selectionConnection) 
  1211.         simplifyOptionsItem;
  1212.  
  1213.     menuItem -label "Euler Filter"
  1214.         -annotation "Euler Filter: Select a curve"        
  1215.         -c ("performEulerFilter " + $realSelectionConnection)
  1216.         eulerFilterItem;
  1217.  
  1218.     menuItem -label "Resample Curve"
  1219.         -annotation "Resample Curve: Select a curve"                
  1220.         -c ("performResample " + $performBase + " " + $selectionConnection)
  1221.         -dragMenuCommand( "performResample " + ($performBase + 2) + " \"" +
  1222.                            $selectionConnection + "\"")
  1223.         resampleItem;
  1224.     menuItem -optionBox true
  1225.         -label "Resample Curve Option Box"
  1226.         -c ("performResample " + ($performBase + 1) + " " + $selectionConnection)
  1227.         resampleOptionsItem;
  1228.  
  1229.     menuItem -label "Spreadsheet..."
  1230.         -annotation "Open the Animation Spreadsheet."
  1231.         -command ("OpenAnimSpreadsheet " + $realSelectionConnection)
  1232.         spreadSheetItem;
  1233.  
  1234.     // Check for the bufferCurve option
  1235.     //
  1236.     if (match ("bufferCurve", $options) == "bufferCurve") {
  1237.         menuItem -label "Buffer Curve Snapshot"
  1238.             -annotation "Buffer Curve Shapshot: Select a curve"
  1239.             -command "bufferCurve -animation \"keys\" -overwrite true"
  1240.             bufferSnapItem;
  1241.         menuItem -label "Swap Buffer Curve"
  1242.             -annotation "Swap Buffer Curve: Select a curve"            
  1243.             -command "bufferCurve -animation \"keys\" -swap"
  1244.             bufferSwapItem;
  1245.     }
  1246.  
  1247.     menuItem -divider true;
  1248.  
  1249.     menuItem -label "Non-weighted Tangents"
  1250.         -annotation "Non-weighted Tangents: Select key(s)"
  1251.         -command ("doKeyTangent \"-edit -weightedTangents false\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1252.     menuItem -label "Weighted Tangents"
  1253.         -annotation "Weighted Tangents: Select key(s)"        
  1254.         -command ("doKeyTangent \"-edit -weightedTangents true\" " + $selectionConnection + " " + "\"" + $options + "\"");
  1255.  
  1256.     if ($buildMenuCommand != "") {
  1257.         eval (($buildMenuCommand + " " + $editor + " " + $animEditor + " " + $parentMenu));
  1258.     }
  1259. }
  1260.  
  1261. global proc
  1262. defineCurvesMenu (string $editor, string $animEditor, string $parentMenu, string $options, string $buildMenuCommand)
  1263. //
  1264. //    Procedure Name:
  1265. //        defineCurvesMenu
  1266. //
  1267. //    Description:
  1268. //        This creates the submenu for curve editing functionality
  1269. //
  1270. //    Example:
  1271. //        Create a menu that this submenu is to be attached to
  1272. //
  1273. //        menuItem -label "Curves"
  1274. //            -allowOptionBoxes false
  1275. //            -subMenu true
  1276. //            curvesHierItem;
  1277. //            defineCurvesMenu $editor $animEditor "curvesHierItem"; 
  1278. //            {further menu items could be defined here}
  1279. //        setParent -m ..;
  1280. //
  1281. //  Input Arguments:
  1282. //        string $editor            The name of the editor that this submenu
  1283. //                                is being attached to
  1284. //        string $parentMenu        The name of the parent menu that this
  1285. //                                submenu is being attached to
  1286. //        string $options            Options for this proc
  1287. //                                Option words are specified within the
  1288. //                                the string, with each option seperated
  1289. //                                by a space (e.g. "bufferCurve otherOption")
  1290. //            Current options:
  1291. //                noOptions        A nice "do nothing" string to pass
  1292. //                bufferCurve        Issue commands to (possibly) create buffer curves
  1293. //
  1294. //  Return Value:
  1295. //      None.
  1296. //
  1297. {
  1298.     setParent -menu $parentMenu;
  1299.     menu -edit
  1300.         -postMenuCommand ("buildCurvesMenu " + $editor + " " + $animEditor + " " + $parentMenu + "\"" + $options + "\"" + " " + "\"" + $buildMenuCommand + "\"")
  1301.         $parentMenu;
  1302. }
  1303.  
  1304. global proc string[]
  1305. findAnimCurves (string $selectionConnection)
  1306. //
  1307. //    Procedure Name:
  1308. //        findAnimCurves
  1309. //
  1310. //    Description:
  1311. //        This is a helper proc which will find a list of animCurves
  1312. //    that are connected to the objects within the specified selection
  1313. //    connection
  1314. //
  1315. //  Input Arguments:
  1316. //        string $selectionConnection
  1317. //                                The name of the selection connection
  1318. //
  1319. //  Return Value:
  1320. //      string[] a list of animCurves
  1321. //
  1322. {
  1323.     string $animCurves[];
  1324.     int $numCurves = 0;
  1325.  
  1326.     // Make sure we have a valid selection connection
  1327.     //
  1328.     if ($selectionConnection == "") {
  1329.         return ($animCurves);
  1330.     }
  1331.     if (!`selectionConnection -query -exists $selectionConnection`) {
  1332.         return ($animCurves);
  1333.     }
  1334.  
  1335.     // Get the list of objects within the selection connection
  1336.     //
  1337.     string $objectList[] = `selectionConnection -query -object $selectionConnection`;
  1338.     if (size ($objectList) == 0) {
  1339.         return ($animCurves);
  1340.     }
  1341.  
  1342.     // Find all the animCurves within the object list
  1343.     //
  1344.     for ($object in $objectList) {
  1345.         if (`isAnimCurve $object` != 1) {
  1346.             continue;
  1347.         }
  1348.         $animCurves[$numCurves] = $object;
  1349.         $numCurves++;
  1350.     }
  1351.  
  1352.     // Now find everything that is connected to the objects in the
  1353.     // object list, and see if they are animCurves
  1354.     //
  1355.     string $connectList[];
  1356.     if (!catch ($connectList = `listConnections -skipConversionNodes true -source true -destination false $objectList`)) {
  1357.         for ($connection in $connectList) {
  1358.             if (`isAnimCurve $connection` != 1) {
  1359.                 continue;
  1360.             }
  1361.             $animCurves[$numCurves] = $connection;
  1362.             $numCurves++;
  1363.         }
  1364.     }
  1365.  
  1366.     return ($animCurves);
  1367. }
  1368.  
  1369. global proc
  1370. OpenAnimSpreadsheet (string $selectionConnection)
  1371. //
  1372. //    Procedure Name:
  1373. //        OpenAnimSpreadsheet
  1374. //
  1375. //    Description:
  1376. //        This is a helper proc to open the attribute editor for
  1377. //        a selected curve (or the first curve if more than one
  1378. //        is selected)
  1379. //
  1380. //  Input Arguments:
  1381. //      None.
  1382. //
  1383. //  Return Value:
  1384. //      None.
  1385. //
  1386. {
  1387.     string $animCurves[];
  1388.  
  1389.     if (`isTrue SomethingSelected` != 0) {
  1390.         catch ($animCurves = `keyframe -an keys -query -name`);
  1391.     }
  1392.     if (size ($animCurves) == 0) {
  1393.         $animCurves = `findAnimCurves $selectionConnection`;
  1394.     }
  1395.  
  1396.     if (size ($animCurves) > 0) {
  1397.         showEditor $animCurves[0];
  1398.     }
  1399.     else {
  1400.         warning ("No keys selected. Please select the animation curve for which you want to view the spreadsheet.");
  1401.     }
  1402. }
  1403.  
  1404. global proc
  1405. loadAnimMenuLibrary ()
  1406. {
  1407. }
  1408.